﻿using System;
using TaskManagerMVVM.DataAccess;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Timers;


namespace TaskManagerMVVM.ViewModel
{
    class ProcessListViewModel : ViewModelBase
    {


        readonly ProcessRetriever _processRetriever;
        readonly SystemPerformance _systemPerformance;
        public ObservableCollection<Process> AllProcesses
        {
            get;
            private set;
        }

        public ObservableCollection<double> MemUsage
        {
            get;
            private set;
        }

        public ObservableCollection<double> CPUUsage
        {
            get;
            private set;
        }

        public ProcessListViewModel(ProcessRetriever processRetriever, SystemPerformance systemPerformance)
        {

            if (processRetriever == null)
            {
                throw new ArgumentNullException("processRetriever");
            }
            _processRetriever = processRetriever;
            this.AllProcesses = new ObservableCollection<Process>(_processRetriever.GetProcesses());


            if (systemPerformance == null)
            {
                throw new ArgumentNullException("CPUUSage");
            }
            _systemPerformance = systemPerformance;
            this.CPUUsage = new ObservableCollection<double>(_systemPerformance.GetCPUUsage());




        }



        protected override void OnDispose()
        {
            this.AllProcesses.Clear();
        }
    }
}
